| Conditions | 3 |
| Total Lines | 59 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import React, { Component } from "react" |
||
| 43 | |||
| 44 | render() { |
||
| 45 | if (this.state.loading === false && this.state.data) { |
||
| 46 | if (this.state.data.length <= 0) { |
||
| 47 | return <></> |
||
| 48 | } |
||
| 49 | const settings_slickslider = { |
||
| 50 | slidesToShow: 3, |
||
| 51 | slidesToScroll: 1, |
||
| 52 | dots: false, |
||
| 53 | arrows: true, |
||
| 54 | centerMode: true, |
||
| 55 | focusOnSelect: true, |
||
| 56 | infinite: true, |
||
| 57 | lazyLoad: true, |
||
| 58 | |||
| 59 | responsive: [ |
||
| 60 | { |
||
| 61 | breakpoint: 1400, |
||
| 62 | settings: { |
||
| 63 | slidesToShow: 3, |
||
| 64 | }, |
||
| 65 | }, |
||
| 66 | { |
||
| 67 | breakpoint: 1200, |
||
| 68 | settings: { |
||
| 69 | slidesToShow: 2, |
||
| 70 | }, |
||
| 71 | }, |
||
| 72 | { |
||
| 73 | breakpoint: 800, |
||
| 74 | settings: { |
||
| 75 | slidesToShow: 1, |
||
| 76 | }, |
||
| 77 | }, |
||
| 78 | ], |
||
| 79 | } |
||
| 80 | |||
| 81 | this.state.data.sort((a, b) => a.dateTime - b.dateTime) |
||
| 82 | |||
| 83 | return ( |
||
| 84 | <div className="matchesSlider--wrapper"> |
||
| 85 | <Slider className={"matchesSlider"} {...settings_slickslider}> |
||
| 86 | {this.state.data.map((match, i) => { |
||
| 87 | return ( |
||
| 88 | <div |
||
| 89 | className="matchesSlider__item" |
||
| 90 | key={i} |
||
| 91 | data-equalizer-watch="true" |
||
| 92 | > |
||
| 93 | <MatchWithLogo match={match} lazyload={false} /> |
||
| 94 | </div> |
||
| 95 | ) |
||
| 96 | })} |
||
| 97 | </Slider> |
||
| 98 | </div> |
||
| 99 | ) |
||
| 100 | } else { |
||
| 101 | return <div>Loading...</div> |
||
| 102 | } |
||
| 125 |